---- start of layout ----
Dataview is a live index and query engine. You can add metadata to notes and query them with the Dataview Query Language (DQL), you can list, filter, sort or group your data without affecting the actual notes. It keeps the queries up to date and always shows the updated data, no need to re-run the query.
Some of many possible use cases:
Dataview gives you a fast way to search, display and operate on indexed data in your vault. With high performance, it can scale up to hundreds of thousands of annotated notes without issue.
If the built in query language is insufficient for your purpose, you can run arbitrary Javascript
against the dataview API, check out the online API reference.
[!Dataview is about displaying, not editing]- Dataview is meant for displaying and calculating data. It is not meant to edit your notes/metadata and will always leave them untouched.
Operates on metadata in your markdown files. Cannot read everything from the vault, only specific data from the [[01_Reference/software tools/YAML|YAML frontmatter]] or from the inline fields via [key::value]
syntax.
Dataview will index information like tags, lists, data from the frontmatter and inline
[key::value]
fields. Only indexed data is available in a dataview query.
After adding useful metadata to markdown files, you will want to display it and operate on it. If your files and data changes, returned data will live-reload, printing relevant and updated information.
REFERENCE (delete later) - https://blacksmithgu.github.io/obsidian-dataview/queries/dql-js-inline/
There are few different ways you can write a query. Using the Dataview Query Language (DQL) written as a codeblock or inline DQL statement. There is also most flexible but most complex way by utilising a Javascript Query and Javascript API. Each style requires different annotation.
[!example]- Click to show more
- DQL code blocks are separated from rest of the content. Opens with three backticks followed by a dataview annotation that will set a type of codeblock
dataview*. Codeblock is closed with three backticks *
- Inline DQL statement can be inserted into rest of the content with a single backtick followed by a equal sign prefix. Inline code to print the filename:
= this.file.name
, print the tag list= this.tags
. Prefix can be configured to another token likedv:
or~
by changing the dataview settings under “Codeblock settings” > “Inline Query Prefix”- Javascript Query and Javascript API gives you the full power of Javascript allowing you to create arbitrarily complex queries and views. Dataview JS blocks are annotated as a ```dataviewjs codeblock
Similar to SQL language. Read about differences to SQL to avoid confusion.
DQL query is created inside a codeblock that uses dataview
as a type. It supports four different query types
to produce different outputs. LIST
, TABLE
, TASK
and CALENDAR
.
[!example]- Click to show more The following example is a
TABLE
query, showingtype
andurl
property values for all files with#personal
tag. Switch to edit mode to preview the syntax.
TABLE type AS “type”, url AS “url” FROM #personal SORT rating DESC
A Inline DQL uses a inline block format instead of a code block. If i type three backticks i will start the code block
# this is bash code block opened with a three ```backticks
export VARIBALE=value
Inline DQL statement is marked with a single backtick followed by an equal sign `= You can reconfigure the settings to another token instead of equal sign under “Codeblock settings” - “Inline Query Prefix”
Switch to edit mode to preview the syntax of inline example
example: Today is = date(today)
[!example]- Click to show more Switch to edit mode to preview the syntax of inline example. The following example is an inline statement showing the properties of
this
object.The filename is
= this.file.name
Last modified time= this.file.mtime
Current tags are= this.tags
Value of type property is= this.type
Value of source property is= this.source
You can either access the properties of the current note via this
object this.file.name
, or access different note via [[link_to_note]].file.name
. Switch to edit mode to view the syntax:
example: =[[_workflow]].file.name
is last modified =[[_workflow]].file.mtime
The present holds infinite possibilities.
---- End of layout ----